package ru.spb.osll.myfit.server.chart;

import com.thoughtworks.xstream.XStream;
import ru.spb.osll.myfit.common.chart.ChartCurve;
import ru.spb.osll.myfit.common.chart.ChartPoint;

import java.io.InputStream;

/**
 * User: Artem Bukhonov
 * Date: 21.04.12
 * Time: 18:48
 */
public class ChartXMLSerializer {
  XStream m_stream = new XStream() {{
    processAnnotations(ChartRenderData.class);
    processAnnotations(ChartCurve.class);
    processAnnotations(ChartPoint.class);
  }};

  public String toXML(ChartRenderData data) {
    return m_stream.toXML(data);
  }

  public ChartRenderData fromXML(String xml) {
    return (ChartRenderData) m_stream.fromXML(xml);
  }

  public ChartRenderData fromXML(InputStream stream) {
    return (ChartRenderData) m_stream.fromXML(stream);
  }
}
